package com.ymttest.database.mongo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.ymt.core.tool.Logger;
import com.ymt.database.MongoDBDriver;

/************************************************************************************
 * @File name :ProductStockInfoWapper.java
 * @Author : yinmeixia
 * @Date : 2016年8月15日
 * @Copyright : 洋码头
 * 商品合库 新库
 ************************************************************************************/
public class ProductStockInfoWapper {
	MongoDBDriver mdd = YmtMongoDriverFactroy.getInstance_YmtProductDBdriver("ProductStockInfo");

	    public ProductStockInfoWapper(){
	    }
		
	    @Deprecated
	    public Map<String, Object> getCatalogId(String catalogId) throws Exception {
	        Map<String, Object> scmb = new HashMap<String, Object>();
	        ArrayList<Map> list = mdd.selectPartLimitToMap("{\"CatalogId\":\"" + catalogId + "\"}",
	                "{'_id':1,'CatalogId':1, 'Earnest':1, 'IsDefault':1, 'NewGuestPrice':1, 'Price':1, 'ProductId':1, 'StockNum':1, "
	                + "'VipPrice':1}", 1, "{'StockNum':-1}");
	        try {
	            if (list.size() > 0) {
	                scmb = list.get(0);
	                return scmb;
	            }
	        } catch (Exception e) {
	            Logger.debug("err data catalogId:" + catalogId);
	            e.printStackTrace();
	        }
	        return null;
	    }
	    
	    public Map<String, Object> getByCatalogId(String catalogId) throws Exception {
	        Map<String, Object> scmb = new HashMap<String, Object>();
	        ArrayList<Map> list = mdd.selectPartLimitToMap("{\"CatalogId\":\"" + catalogId + "\"}",1);
	             try {
	            if (list.size() > 0) {
	                scmb = list.get(0);
	                return scmb;
	            }
	        } catch (Exception e) {
	            Logger.debug("err data catalogId:" + catalogId);
	            e.printStackTrace();
	        }
	        return null;
	    }
	    
	    public Map<String, Object> getByProductId(String productId) throws Exception {
	        Map<String, Object> scmb = new HashMap<String, Object>();
	        ArrayList<Map> list = mdd.selectPartLimitToMap("{\"ProductId\":\"" + productId + "\"}",1);
	             try {
	            if (list.size() > 0) {
	                scmb = list.get(0);
	                return scmb;
	            }
	        } catch (Exception e) {
	            Logger.debug("err data productId:" + productId);
	            e.printStackTrace();
	        }
	        return null;
	    }
	    
	    
	    public static void main(String[] args) throws Exception {
	    	Map<String, Object> aa= new ProductStockInfoWapper().getByCatalogId("5aa7973c-f2c6-42ea-92da-ddd57953de2e");
	    	System.out.println(new ProductBasicInfoWapper().getByProductId("0cf6f3a0-9521-4e4e-84e2-c6e4800eb723").get("ProductId"));
	    	int c=1;
		}
}
